import matplotlib.pyplot as plt
import numpy as np
from test_4_00 import create_polar_system

# 创建极坐标系
fig, ax = create_polar_system(r_range=(0, 5))

# θ值范围[0,2π]
theta = np.linspace(0, 2*np.pi, 200)
color = 'r'
a = 2

# 绘制圆
# 计算ρ值：ρ = -acosθ
p = -a * np.cos(theta)
ax.plot(theta, p, 'b--', linewidth=2, 
        label=f'ρ = -acosθ')

# 绘制曲线
# 计算ρ值：ρ = a(1-cosθ)
p1 = a*(1-np.cos(theta))
ax.plot(theta, p1, 'b--', linewidth=2, 
        label=f'ρ = a(1-cosθ)')


# 添加图例
ax.legend(loc='upper right', bbox_to_anchor=(1.15, 1.15))

# 标记极点
ax.plot(0, 0, 'ko', markersize=6, label='极点')
ax.text(0.1, 0.3, 'O', fontsize=10, color='black')

plt.tight_layout()
plt.show()